﻿#region License

//     This file is part of TCP Sender.
// 
//     TCP Sender is free software: you can redistribute it and/or modify
//     it under the terms of the GNU General Public License as published by
//     the Free Software Foundation, either version 3 of the License, or
//     (at your option) any later version.
// 
//     TCP Sender is distributed in the hope that it will be useful,
//     but WITHOUT ANY WARRANTY; without even the implied warranty of
//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//     GNU General Public License for more details.
// 
//     You should have received a copy of the GNU General Public License
//     along with TCP Sender.  If not, see <http://www.gnu.org/licenses/>

#endregion

/*
 * Created by Error218
 * 25/07/2012
 * 22:12
 */

using System;
using System.Windows.Forms;
using PacketDotNet;
using SharpPcap;
using SharpPcap.LibPcap;


namespace Packet_Sender
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();              // Drawing the form...
        }
        
        private void Form1_Load(object sender, EventArgs e)
        {
            foreach (var dev in Globals.devices)
            {
                DeviceList.Items.Add(dev.Description);      // Switching the devices and adding to listbox...
            }
            if (DeviceList.Items.Count > 0)
                DeviceList.SelectedIndex = 0;               // Anti-bug by Exit93 (Metin2 Server Emulator).
        }

        private void btnRefresh_Click(object sender, EventArgs e)
        {
            DeviceList.Items.Clear();                           // Deleting all items in the listbox...
            Globals.devices = LibPcapLiveDeviceList.New();      // Refreshing devices list variable...
            foreach (var dev in Globals.devices)                // Refreshing the devices list...
            {
                DeviceList.Items.Add(dev.Description);
            }
            if (DeviceList.Items.Count > 0)
                DeviceList.SelectedIndex = 0;
        }

        private void btnSelect_Click(object sender, EventArgs e)
        {
            Globals.currentDevice = Globals.devices[DeviceList.SelectedIndex];      // Setting currentDevice as selected device.
            this.Close();                                                           // I close the form,
                                                                                    // See Program.cs for understand program logic.
            
        }
    }



    
}
